home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Files / Directory.s < prev   
Text File  |  1997-12-10  |  3KB  |  89 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Directory List.
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This demo lists files and directories from "GMS:" in the IceBreaker window.
  7.  
  8.     INCDIR    "INCLUDES:"
  9.     INCLUDE    "dpkernel/dpkernel.i"
  10.     INCLUDE    "files/segments.i"
  11.     INCLUDE    "system/debug.i"
  12.  
  13.     SECTION    "Demo",CODE
  14.  
  15. ;===========================================================================;
  16. ;                             INITIALISE DEMO
  17. ;===========================================================================;
  18.  
  19.     STARTDPK
  20.  
  21. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  22.     move.l    DPKBase(pc),a6
  23.     lea    DirTags(pc),a0    ;a0 = Directory tags.
  24.     sub.l    a1,a1
  25.     CALL    Init    ;>> = Open the directory.
  26.     tst.l    d0
  27.     beq.s    .Exit
  28.  
  29.     move.l    Directory(pc),a0    ;a0 = Directory Object.
  30.     CALL    Activate    ;>> = Get a directory list.
  31.  
  32.     bsr.s    PrintDirectory
  33.  
  34. .Exit    move.l    Directory(pc),a0
  35.     CALL    Free
  36.     MOVEM.L    (SP)+,A0-A6/D1-D7
  37.     moveq    #ERR_OK,d0
  38.     rts
  39.  
  40. ;===========================================================================;
  41. ;                         PRINT DIRECTORY STRUCTURE
  42. ;===========================================================================;
  43.  
  44. PrintDirectory:
  45.     move.l    Directory(pc),a0    ;a0 = Directory.
  46.     move.l    DIR_ChildDir(a0),a0    ;a0 = DirList.
  47. .dirlp    cmp.l    #$00,a0
  48.     beq.s    .filelist
  49.     move.l    DIR_Source(a0),a1    ;a1 = FileName.
  50.     moveq    #DBG_Message,d7    ;d7 = Message.
  51.     move.l    FN_Name(a1),a5    ;a5 = Name of file.
  52.     CALL    DebugMessage    ;>> = Send the message.
  53.     move.l    DIR_Next(a0),a0    ;a0 = Next directory.
  54.     bra.s    .dirlp    ;>> = Keep looping.
  55.  
  56. .filelist
  57.     move.l    Directory(pc),a0    ;a0 = Directory.
  58.     move.l    DIR_ChildFile(a0),a0    ;a0 = DirList.
  59. .filelp    cmp.l    #$00,a0
  60.     beq.s    .end
  61.     move.l    FL_Source(a0),a1    ;a1 = FileName.
  62.     moveq    #DBG_Message,d7    ;d7 = Message.
  63.     move.l    FN_Name(a1),a5    ;a5 = Name of file.
  64.     CALL    DebugMessage    ;>> = Send the message.
  65.     move.l    FL_Next(a0),a0    ;a0 = Next directory.
  66.     bra.s    .filelp    ;>> = Keep looping.
  67. .end    rts
  68.  
  69. ;===========================================================================;
  70. ;                                  DATA
  71. ;===========================================================================;
  72.  
  73. DirTags:    dc.l  TAGS_DIRECTORY
  74. Directory:    dc.l  0
  75.         dc.l  DIRA_Source,.dir
  76.         dc.l  TAGEND
  77.  
  78. .dir        FILENAME "GMS:"
  79.  
  80. ;===========================================================================;
  81.  
  82. ProgName:    dc.b  "Directory List",0
  83. ProgAuthor:    dc.b  "Paul Manias",0
  84. ProgDate:    dc.b  "10 December 1997",0
  85. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1997.  Freely distributable.",0
  86. ProgShort:    dc.b  "Lists the files in a directory.",0
  87.         even
  88.  
  89.